package org.mspring.mlog.api.spider.service;

import java.util.List;

import org.mspring.mlog.api.spider.dao.SpiderRuleDao;
import org.mspring.mlog.api.spider.entity.SpiderRule;
import org.mspring.platform.dao.Page;
import org.mspring.platform.dao.query.QueryBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author Gao Youbo
 * @since 2013-3-8
 */
@Service
@Transactional
public class SpiderRuleService {

    @Autowired
    private SpiderRuleDao spiderRuleDao;

    public long create(SpiderRule rule) {
        rule.setEnabled(true);
        return spiderRuleDao.insert(rule);
    }

    public List<SpiderRule> listAllEnabledRules() {
        return spiderRuleDao.listAllEnabledRules();
    }

    public Page<SpiderRule> listPage(QueryBuilder queryBuilder, Page<SpiderRule> page) {
        return spiderRuleDao.listPage(queryBuilder, page);
    }

    public SpiderRule get(long id) {
        return spiderRuleDao.get(id);
    }

    public void delete(Long... id) {
        spiderRuleDao.delete(id);
    }

    public void update(SpiderRule spiderPost) {
        spiderRuleDao.update(spiderPost);
    }
}
